Example

In this lesson, we'll introduce an example.

The domain structure is identical to the example in the Netflix chapter (chapter 10) (see the drawing below) and consists of three microservices.

svg viewer
Architecture of the Consul Example
  • The catalog microservice manages the information such as price and name for the items that can be ordered.

  • The customer microservice stores customer data.

  • The order microservice can accept new orders. It uses the catalog and customer microservice.

Architecture of the example#

The example in this chapter uses Consul for service discovery and Apache httpd server for routing the HTTP requests.

An overview of the Docker containers is shown in the drawing below. The three microservices provide their UI and REST interfaces at the port 8080. They are only accessible within the network between the Docker containers. Consul offers port 8500 for the REST interface and the HTML UI as well as UDP port 8600 for DNS requests.

These two ports are bound to the Docker host and are accessible from other computers. The Docker host also provides the Apache httpd at port 8080. Apache httpd forwards calls to the microservices in the Docker network so that the microservices can also be accessed from outside.

svg viewer
Overview of the Consul Example

Building the example#

First download the code with git clone https://github.com/ewolff/microservice-consul.git. Then the code has to be translated with ./mvnw clean package (macOS, Linux) or mvnw.cmd clean package (Windows) in directory microservice-consul-demo. See this lesson for more details on Maven and how to troubleshoot the build. Afterwards the Docker containers can be built in the directory docker with docker-compose build and started with docker-compose up -d. See this lesson for more details on Docker, docker-compose and how to troubleshoot them. Subsequently, the Docker containers are available on the Docker host.

When the Docker containers are running on the local computer, the following URLs are available:

https://github.com/ewolff/microservice-consul/blob/master/HOW-TO-RUN.md describes the necessary steps for building and running the example in detail.


In the next lesson, we’ll look at service discovery with Consul.

Introduction
Service Discovery
Mark as Completed
Report an Issue